package jst.btremote.bluetooth;

public class CommandBuilder {

	public static String buildRGBMessage(int red, int green, int blue) {
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append('L');
		stringBuilder.append(String.format("%03d", red));
		stringBuilder.append(String.format("%03d", green));
		stringBuilder.append(String.format("%03d", blue));
		return stringBuilder.toString();
	}
	
	public static String buildRedLEDMessage(int value) {
		return buildSingleLEDMessage('R', value);
	}
	
	public static String buildGreenLEDMessage(int value) {
		return buildSingleLEDMessage('G', value);
	}
	
	public static String buildBlueLEDMessage(int value) {
		return buildSingleLEDMessage('B', value);
	}
	
	private static String buildSingleLEDMessage(char color, int value) {
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append(color);
		stringBuilder.append(String.format("%03d", value));
		return stringBuilder.toString();
	}

	public static String buildColorGradient(int redX, int greenX, int blueX, int redY, int greenY, int blueY, int time) {
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append('X');
		stringBuilder.append(String.format("%03d", redX));
		stringBuilder.append(String.format("%03d", greenX));
		stringBuilder.append(String.format("%03d", blueX));
		stringBuilder.append(String.format("%03d", redY));
		stringBuilder.append(String.format("%03d", greenY));
		stringBuilder.append(String.format("%03d", blueY));
		stringBuilder.append(String.format("%03d", time));
		return stringBuilder.toString();
	}
	
	public static String buildAutoGradient(Boolean start) {
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append('A');
		if(start) {
			stringBuilder.append('S');
		} else {
			stringBuilder.append('E');
		}
		return stringBuilder.toString();
	}
	
}
